<template>
  <div class="count">
    <h2>当前求和为：{{ sum }}</h2>
    <h2>当前的学校：{{ school }}</h2>
    <h2>当前的地址：{{ address }}</h2>
    <hr>
    <h2>当前和乘10：{{ bigSum }}</h2>
    <h2>学校名（大写）：{{ bigSchool }}</h2>
    <select v-model.number="n">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
    <button @click="JIA(n)">+</button>
    <button @click="JIAN(n)">-</button>
    <button @click="oddAdd(n)">当前和为奇数+</button>
    <button @click="waitAdd(n)">等一等+</button>
    <button @click="serverAdd">问问服务器怎么+</button>
  </div>
</template>

<script>
  import { mapGetters, mapState,mapActions, mapMutations } from 'vuex'
  export default {
    name:'Count',
    data() {
      return {
        n:1,
      }
    },
    computed: {
      ...mapState(['sum','school','address']),
      ...mapGetters(['bigSum','bigSchool'])
    },
    methods: {
      /* add(){
        this.$store.commit('JIA',this.n)
      },
      minus(){
        this.$store.commit('JIAN',this.n)
      }, */

      /* ...mapMutations({
        add:'JIA',
        minus:'JIAN'
      }), */
      ...mapMutations(['JIA','JIAN']),

      ...mapActions({
        oddAdd:'jijia',
        waitAdd:'dengjia',
        serverAdd:'fuwuJia'
      })
      // ...mapActions(['jijia','dengjia','fuwuJia'])
    },
  }
</script>

<style scoped>
  .count {
    background-color: skyblue;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
  }
  button {
    margin: 0 5px;
  }
</style>